/*
 * DNuevaCuentaOrUsuario.java
 *
 * Created on 18 de mayo de 2006, 02:42 PM
 */

package ig.metrica.ui.seguridad;

/**
 *
 * @author  jsanchez
 */
public class DNuevaCuentaOrUsuario extends javax.swing.JDialog {
    
    MUsuarios modelo=null;
    /** Creates new form DNuevaCuentaOrUsuario */    
    public DNuevaCuentaOrUsuario(MUsuarios modelo,java.awt.Frame parent, boolean modal) {        
        super(parent, modal);
        this.modelo=modelo;
        initComponents();
        java.awt.Dimension dimensionScreen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Rectangle dimensionPantalla = getBounds();
        setLocation((dimensionScreen.width - dimensionPantalla.width) / 2, (dimensionScreen.height - dimensionPantalla.height) / 2);                
        this.setVisible(true);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        cuenta = new javax.swing.JRadioButton();
        usuario = new javax.swing.JRadioButton();
        Aceptar = new javax.swing.JButton();
        Cancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Que desea crear");

        buttonGroup1.add(cuenta);
        cuenta.setFont(new java.awt.Font("Dialog", 0, 12));
        cuenta.setSelected(true);
        cuenta.setText("Cuenta relacionado al usuario seleccionado");
        cuenta.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        cuenta.setMargin(new java.awt.Insets(0, 0, 0, 0));

        buttonGroup1.add(usuario);
        usuario.setFont(new java.awt.Font("Dialog", 0, 12));
        usuario.setText("Usuario");
        usuario.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        usuario.setMargin(new java.awt.Insets(0, 0, 0, 0));
        usuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                usuarioActionPerformed(evt);
            }
        });

        Aceptar.setText("Aceptar");
        Aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AceptarActionPerformed(evt);
            }
        });

        Cancelar.setText("Cancelar");
        Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelarActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
                            .add(usuario, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
                            .add(cuenta, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)))
                    .add(layout.createSequentialGroup()
                        .add(45, 45, 45)
                        .add(Aceptar)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(Cancelar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cuenta)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(usuario)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Aceptar)
                    .add(Cancelar))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void usuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usuarioActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_usuarioActionPerformed

    private void CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelarActionPerformed
        modelo.setNuevoUsuario(null);
        this.dispose();
    }//GEN-LAST:event_CancelarActionPerformed

    private void AceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AceptarActionPerformed
        if(this.cuenta.isSelected())
            modelo.setNuevoUsuario(false);
        else if(this.usuario.isSelected())
            modelo.setNuevoUsuario(true);
        else 
            modelo.setNuevoUsuario(null);
        this.dispose();
    }//GEN-LAST:event_AceptarActionPerformed
    
//        /**
//         * @param args the command line arguments
//         */
//        public static void main(String args[]) {
//            java.awt.EventQueue.invokeLater(new Runnable() {
//                public void run() {
//                    new DNuevaCuentaOrUsuario(new javax.swing.JFrame(), true).setVisible(true);
//                }
//            });
//        }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Aceptar;
    private javax.swing.JButton Cancelar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton cuenta;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JRadioButton usuario;
    // End of variables declaration//GEN-END:variables
    
}
